/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author riccardo
 */
@Entity
@Table(name = "HOTEL")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Hotel.findAll", query = "SELECT h FROM Hotel h"),
    @NamedQuery(name = "Hotel.findByIdHOTEL", query = "SELECT h FROM Hotel h WHERE h.idHOTEL = :idHOTEL"),
    @NamedQuery(name = "Hotel.findByStelle", query = "SELECT h FROM Hotel h WHERE h.stelle = :stelle"),
    @NamedQuery(name = "Hotel.findByRecapito", query = "SELECT h FROM Hotel h WHERE h.recapito = :recapito")})
public class Hotel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idHOTEL")
    private Integer idHOTEL;
    @Column(name = "stelle")
    private Integer stelle;
    @Size(max = 255)
    @Column(name = "recapito")
    private String recapito;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idHOTEL")
    private Collection<Camera> cameraCollection;
    @JoinColumn(name = "indirizzo", referencedColumnName = "CAP")
    @ManyToOne
    private Citta indirizzo;

    public Hotel() {
    }

    public Hotel(Integer idHOTEL) {
        this.idHOTEL = idHOTEL;
    }

    public Integer getIdHOTEL() {
        return idHOTEL;
    }

    public void setIdHOTEL(Integer idHOTEL) {
        this.idHOTEL = idHOTEL;
    }

    public Integer getStelle() {
        return stelle;
    }

    public void setStelle(Integer stelle) {
        this.stelle = stelle;
    }

    public String getRecapito() {
        return recapito;
    }

    public void setRecapito(String recapito) {
        this.recapito = recapito;
    }

    @XmlTransient
    public Collection<Camera> getCameraCollection() {
        return cameraCollection;
    }

    public void setCameraCollection(Collection<Camera> cameraCollection) {
        this.cameraCollection = cameraCollection;
    }

    public Citta getIndirizzo() {
        return indirizzo;
    }

    public void setIndirizzo(Citta indirizzo) {
        this.indirizzo = indirizzo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idHOTEL != null ? idHOTEL.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hotel)) {
            return false;
        }
        Hotel other = (Hotel) object;
        if ((this.idHOTEL == null && other.idHOTEL != null) || (this.idHOTEL != null && !this.idHOTEL.equals(other.idHOTEL))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Hotel[ idHOTEL=" + idHOTEL + " ]";
    }
    
}
